const http = require('http')
const fs   = require('fs')
const config = require('./config')

const server = http.createServer((req, res) => {
    const url = req.url
    if (url === '/favicon.ico') {
        return ;
    }

    res.writeHead(200, {'Content-Type': 'text/html;charset=UTF-8'})
    fs.readFile('./static/index.html', (err, data) => {
        if (err) {
            throw err
        }
        res.end(data)
    })
})

server.listen(config.port, config.hostname, () => {
    console.log('server running on port ', config.port)
})